<%-- 
    Document   : thanhtoan
    Created on : Dec 8, 2011, 10:57:07 PM
    Author     : BlueZky
--%>

<%@page import="net.tanesha.recaptcha.ReCaptchaFactory"%>
<%@page import="net.tanesha.recaptcha.ReCaptcha"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<link rel="stylesheet" type="text/css" href="styles/userstyles.css" />
<link rel="stylesheet" type="text/css" href="styles/simple.css" />
<!DOCTYPE html>
<div class="content">
    <div class="partion" style="padding-top: 20px;">
        <div class ="title">Xác nhận đơn đặt hàng</div>
        <c:if test="${message ne null}">
            <div class="rerror">${message}</div>
        </c:if>
        <div class="utitle">Thông tin người nhận</div>

        <table>
            <tr>
                <td class="cell-left"><b>Tên người nhận</b></td>
                <td class="cell-right"  style="border-right: none; color: orange;"><b>${sessionScope.hoaDon.nguoinhan}</b></td>
            </tr>
            <tr>
                <td class="cell-left"><b>Địa chỉ </b></td>
                <td class="cell-right "  style="border-right: none; color: orange;"><b>${sessionScope.hoaDon.diachinhan}</b></td>
            </tr>
            <tr>
                <td class="cell-left"><b>Số điện thoại</b></td>
                <td class="cell-right "  style="border-right: none; color: orange;"><b>${sessionScope.hoaDon.sodtnhan}</b></td>
            </tr>
            <tr>
                <td class="cell-left"><b>CMND</b></td>
                <td class="cell-right"  style="border-right: none; color: orange;"><b>${sessionScope.hoaDon.cmndnhan}</b></td>
            </tr>         

        </table>
        <div class="utitle" style="margin-top: 20px;">Danh sách sản phẩm đặt mua</div>
        <div class="box">
            <c:if test="${sessionScope.gioHang.size() gt 0}">
                <c:set var="sum" value="0"></c:set>
                <c:set var="soluong" value="0"></c:set>
                <c:set var="khuyenmai" value="0"></c:set>
                <c:forEach items="${sessionScope.gioHang}" var="item" varStatus="status">
                    <c:set var="sum" value="${sum + item.gia*item.soluongton}"></c:set>
                    <c:set var="soluong" value="${soluong + item.soluongton}"></c:set>
                </c:forEach>

                <form method="post" action="thanhtoan.htm?a=o">
                    <table class="utable" cellspacing="0px" cellpadding="10px" >
                        <tr>
                            <th style="width:20px;">STT</th>
                            <th>Sản phẩm</td>
                            <th style="width:50px;">Số lượng</th>
                            <th style="width:70px;">Đơn giá</th>
                            <th style="width:70px;">Khuyến mãi</th>
                            <th style="width:100px;">Thành tiền</th>
                            <th style="border-right: none;"></th>
                        </tr>
                        <c:forEach items="${sessionScope.gioHang}" var="item" varStatus="status">
                            <tr >
                                <td>${status.index + 1}</td>
                                <td><a href="chitiet.htm?PID=${item.masp}" style="color: #00CED1;">${item.tensp}</a></td>
                                <td>${item.soluongton}</td>
                                <td style="text-align: right">${item.gia} $</td>
                                <td style="text-align: right">0</td>
                                <td style="border-right: none;"><b><fmt:formatNumber value="${item.soluongton*item.gia}" maxFractionDigits="2"/>$</b></td>
                                <td style="border-right: none;"><a href="giohang.htm?a=d&pid=${item.masp}"><img src="images/delete.png" width="28px" alt="delete" /></a></td>
                            </tr>
                        </c:forEach>
                        <tr>
                            <td colspan="5"  style="text-align: center">Thành tiền</td>
                            <td colspan="2" class="ucart" style="border-right: none; color: orange;"><fmt:formatNumber value="${sum}" maxFractionDigits="2"/>  $</td>
                        </tr>
                        <tr>
                            <td colspan="5"  style="text-align: center">Khuyến mãi</td>
                            <td colspan="2" class="ucart" style="border-right: none; color: orange;">${khuyenmai} $</td>
                        </tr>
                        <tr>
                            <td colspan="5"  style="text-align: center">Thanh toán</td>
                            <td colspan="2" class="ucart" style="border-right: none; color: orange;"><fmt:formatNumber value="${sum-khuyenmai}" maxFractionDigits="2"/>  $</td>
                        </tr>
                        <tr>
                            <td colspan="3" rowspan="2" style="border: none;">
                                Nhập mã xác thực
                                <%
                                    ReCaptcha c = ReCaptchaFactory.newReCaptcha("6LcinsgSAAAAAK7vyXsp5J2K4rPFDNYJxBo2C3mW", "6LcinsgSAAAAANc_pVTmCEL8lxeHmAucwl7DvMUh", false);
                                    out.print(c.createRecaptchaHtml(null, null));
                                %>
                            </td>
                            <td colspan="2"   style="border:  none;">
                                    <div class="btn-buy" style="font-size: 20px; 
                                         font-family: sans-serif; 
                                         padding: 0 10px 0 10px; 
                                         float: left;" onclick="submit()">
                                        <input type="image" src="images/check.png" alt="Thanh toán" align="middle"/> Đặt hàng
                                    </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="border:none;">
                                <a href="thanhtoan.htm"><div class="btn-buy" 
                                                             style="font-size: 20px; 
                                                             font-family: sans-serif; 
                                                             padding: 0 10px 0 10px;
                                                             cursor: pointer;
                                                             float:left;" >

                                        <img src="images/back.png" align="middle"/>Quay lại</div>
                                </a>
                            </td>
                        </tr>

                    </table>
                </form>
            </c:if>
        </div>
    </div>
</div>
